Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Creating copies of Apple events with ODDescTOAEDesc
If you send a Semantic Event to yourself and, in your handler, you make a copy of the event with ODDescToAEDesc, you must use the utility ODDisposeAppleEvent to dispose the resultant AppleEvent. This utility simply calls AEDisposeDesc twice to assure that the event is disposed. The use of this utility is always safe since, if the first call to AEDisposeDesc succeeds, the AppleEvent will be turned into a NULL descriptor and it is always safe to pass a NULL descriptor to AEDisposeDesc. The Apple event manager is clever about not letting you dispose of an event that is not yet finished being processed. Even though the event you created with ODDescToAEDesc is a copy and not the original event, it looks like the original event to the Apple event Manager.
Reentrancy of ODNameResolver::Resolve
This method is now reentrant.
Documents created from stationery (mismatched Finder and Process Manager names)
[This bug was not fixed for OpenDoc 1.0, so this is still a concern.]
When a document is created from stationery, the stationery is launched by the process manager, but the newly created document is then attached to the existing process by OpenDoc. The name of the document in the application menu is the name of the stationery document, but OpenDoc thinks the name is the new document name. When AppleScript searches by name for an application to target, it first checks the application menu, and it will match against the stationery file name. Subsequent launches of the document won’t have this problem. The first time the document is launched, you will need a tell statement like this (typically):
tell application "TextEditor 1.0"
The next time(s) you will have to change it to something like this:
tell application "TextEditor 1.0 5/7/95"
Unsupported/problematic script syntax
Executing a script such as “every part of (every part whose name is not equal to "James")” does not lead to the desired results. Instead you get a result that would be the same the result you would get from executing “every part whose name is not equal to "James"”. We think the OSL is collapsing the every part of every part expression.
The default object accessors do not support property-from-property. For example, scripts that reference “name of container of…” won’t work. The workaround is to write this line like this: “name of (get container of…)”.
Whose clauses where the container is a list, e.g., “(every part whose name is not equal to "foo ") of every part”, may not always work correctly.
Object specifiers in the data descriptors are not supported. For example, the script “set comment of part 1 to comment” fails because the default accessor for properties does not know how to get the comment of the root part. If you make AppleScript do the work, i.e., “set comment of part 1 to (get comment)”, this will work.
Unsupported forms
There is no way to iterate through every part in a document unless you do it manually, i.e., build a list of parts embedded in the root part, then iterate through that list, building a list of the embedded parts for each one of the parts in the list, etc.
There is no way to get the index or the container of the root part. It doesn’t make sense.
Stuff that doesn’t work right
Setting the icon of a part via scripting doesn’t work right.
Memory Leaks
We have tried to squash every known memory leak in OpenDoc's semantic event processing, but a few are still left. Very simple events should not leak, but events that produce lists or that contain object specifiers with whose clauses may produce small memory leaks in OpenDoc code.
Subject attribute
OpenDoc now uses the subject attribute of an event when appropriate and will attach a subject attribute to events sent with ODMessageInterface::Send. See the Programmer's Guide for more details.
'aete' resources for parts
OpenDoc now automatically gathers the aete resources for all part editors installed and makes them available to AppleScript. This will greatly simplifying the scripter's task.
The Object Support Library
OpenDoc includes its own version of the Object Support Library. You should use the methods of ODNameResolver and ODSemanticInterface instead of the routines defined in the OSL. You should not mix calls to the OSL (routines found in AEObjects.h) with calls to ODNameResolver. There are a few OSL calls that can be used, however. These are the routines defined in AEPackObject.h.
NULL Container Tokens
When you expect a NULL token as the container of an object accessor, you may get an OpenDoc token instead. But you may have a NULL token. You must examine the “user” token to see if it is NULL or not.
Redispatching object accesses
When handling an object dispatch where you are asked to create a list, you may wish to use the CallObjectAccessor method of ODNameResolver to repeatedly call, in a loop, the object accessor for a single item. If you do this, you must create a new token for each call to CallObjectAccessor. Use the DuplicateODOSLToken method of ODOSLToken to correctly create a new token for use. This method correctly clones an OpenDoc token copying the internal structures.
Using pre-dispatch handlers
You should never return anything other than errAEEventNotHandled from a pre-dispatch function unless you are writing a patch on the Semantic Events subsystem of OpenDoc. If you return noErr, you will have consumed the event and OpenDoc code will never get a chance to send the event to the destination part.
Scripting samples
The CD includes of a number of examples on how to implement scripting in your part editor. There are two examples of how to create a subclass of the ODSemanticInterface class. One example uses a pre-written template class called ODCPlusSemanticInterface which in turn uses a C++ helper class, SIHelper. These classes may be found among the OpenDoc utilities. The other example furnishes a template SOM class that is a simple subclass of ODSemanticInterface. The methods of this class contain boilerplate code and comments that should help you get started quickly with writing event handles and object accessors.
All of the utility code that is needed to use ODCPlusSemanticInterface should now be available with the OpenDoc utilities.
The sample code parts also contain an example of a scriptable part. The SoundEditor part editor supports play, record, stop, etc.